Repository navigation
Conversation
Add FS.ZFSDDTStats, which reads the OpenZFS dedup table (DDT) statistics from /proc/spl/kstat/zfs/<pool>/ddt_stats_<checksum>. These files exist on OpenZFS 2.3 and later, one per dedup-capable checksum per pool. Pool and checksum are taken from the file path. Rows are parsed from the named kstat table; both UINT32 (the *_rate fields) and UINT64 values are returned as uint64, and unknown field names are ignored so that new ZFS fields do not break parsing. A system without these files returns an empty result rather than an error. Fixtures are captured from OpenZFS 2.3 on Debian 13. This is needed for node_exporter's zfs collector: prometheus/node_exporter#3435 Signed-off-by: Natneam M <58377289+natneam@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a parser for the OpenZFS dedup table (DDT) statistics in
/proc/spl/kstat/zfs/<pool>/ddt_stats_<checksum>, so node_exporter's zfscollector can expose them (see prometheus/node_exporter#3435). This is the first
ZFS code in procfs.
What it does
FS.ZFSDDTStats()globsspl/kstat/zfs/*/ddt_stats_*and returns oneZFSDDTStatsper file:filename with
ddt_stats_trimmed). A DDT belongs to the whole pool, sothere is no dataset.
edonr and blake3 files for every pool, and only the checksum in use has
non-zero values.
name type data). The three*_ratefields areKSTAT_DATA_UINT32; the rest areKSTAT_DATA_UINT64.All of them are returned as
uint64.don't break parsing.
than 2.3 and systems without ZFS.
Field definitions are in
ddt_kstats_templateinmodule/zfs/ddt.c.
The counters reset each time the pool is imported.
Reading is done with
parsers.ReadFileNoStat(these files report size 0),and parsing is a separate function, following CONTRIBUTING.md.
Testing
ddt_stats_sha256andddt_stats_blake3forpool1,captured unmodified from OpenZFS 2.3 on Debian 13.
the UINT32 rate fields. The sha256 values are internally consistent, e.g.
lookup800 =lookup_new400 +lookup_existing400.parseZFSDDTStatscovering empty input,a missing header, a non-numeric value, an unknown field name, an unexpected
type, and a UINT32 row.
make testandmake lintpass.Follow-up
Once this is released, I'll open a node_exporter PR that uses
fs.ZFSDDTStats()to add DDT metrics to the zfs collector. That adds 17metrics per checksum file, which is 85 series per pool (5 checksums × 17
fields).
cc @SuperQ @discordianfish